﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using HZ.MBSM.DBUtility;
public partial class Company_BoardAddbyc : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        string strSql, Id;
        if (HZ.MBSM.BLL.Login.CheckAssert(this.UseAccountType))
        {
            if (!IsPostBack)
            {
                lstExplainState.SelectedIndex = 1;
            }
            if (Request.Form["btnSubmit"] == "删除" && Request.Form["chk"] != null)
            {
                Id = Request.Form["chk"].ToString();
                strSql = "delete from board where Id in (" + Id + ")";
                Db db = new Db();
                db.Command(strSql);
                db.Close();
                HZ.MBSM.Model.Account _Account = (HZ.MBSM.Model.Account)Session["Account"];
                HZ.MBSM.BLL.LogManage.RecordLoginDetail(_Account.AccountName, Request.UserHostAddress, "删除", "board", strSql, "../Magage/BoardList.aspx");
            }
            ShowDate();
        }
    }

    public void ShowDate()
    {
        string strConditions;
        strConditions = fctConditions();
        Db db = new Db();
        DbPage dbPage = new DbPage(db);
        dbPage.Table = "dbo.Board LEFT OUTER JOIN " +
     " dbo.v_account v_account_1 ON " +
    "  dbo.Board.AnswerId = v_account_1.accountid LEFT OUTER JOIN" +
     " dbo.v_account ON dbo.Board.AccountId = dbo.v_account.accountid";                                               //要查询的表明
        dbPage.Key = "id";                                               //表的主键    
        dbPage.Where = strConditions;                                           //查询条件    
        dbPage.SelectField = "ID, CreateDate, Board.AccountId, Tiwenren,AnswerId,  left(isnull(Explain,''),30) as Explain, left(Content,30) as Content,AnswerDate, Title , dbo.v_account.DWName AS wname,v_account_1.DWName AS dname,v_account.accountname";//要显示的字段
        dbPage.PageIndex = SysFun.ToInt(Request["CurrentlyPageIndex"]);          //要显示第几页   
        dbPage.PageSize = 10;                                                    //没有显示记录条数   
        dbPage.OrderBy = "id";                  //排序字段
        dbPage.OrderByIsDesc = true;
        System.Data.IDataReader dr = dbPage.ExecuteReader();
        DlAttorney.DataSource = dr;
        DlAttorney.DataBind();
        dr.Close();
        dr.Dispose();
        dbPage.Db.Close();
        db.Close();

        this.DbPageFlip1.DbPage = dbPage;//将数据传给控键




    }
    /// <summary>
    /// 生成查询条件
    /// </summary>
    /// <returns></returns>
    public string fctConditions()
    {
        HZ.MBSM.Model.Account _Account = (HZ.MBSM.Model.Account)Session["Account"];
        string _strTemp = "Board.AccountId='" + _Account .AccountId+ "' and";
        string _strTitle = txtTitle.Text.ToString().Trim();
        //标题
        if (_strTitle != "")
        {
            _strTemp = " Title like '%" + _strTitle + "%' and";
        }

        //提问人名称

        

        //答复状态

        string _strExplainState = lstExplainState.SelectedItem.Text;
        switch (_strExplainState)
        {
            case "全部":
                break;
            case "已答复":
                _strTemp += " Explain is not  null and";
                break;
            case "未答复":
                _strTemp += " Explain is  null and";
                break;

        }

        if (_strTemp != "")
        {
            _strTemp = "  " + _strTemp.Substring(0, _strTemp.Length - 3);
        }

        return _strTemp;

    }
    #region IPageDescribe 成员


    public string Describe
    {
        get { return ""; }
    }
    public string Name
    {
        get { return "问题反馈列表"; }
    }
    public string ParentName
    {
        get { return "问题反馈"; }
    }

    public System.Collections.Generic.List<HZ.MBSM.DAL.AccountType> UseAccountType
    {
        get
        {
            System.Collections.Generic.List<HZ.MBSM.DAL.AccountType> _AccountType = new System.Collections.Generic.List<HZ.MBSM.DAL.AccountType>();
            _AccountType.Add(HZ.MBSM.DAL.AccountType.enumCompany);
            return _AccountType;
        }
    }

    #endregion
}
